#region Usings

using System;
using System.Collections.Generic;
using System.Linq;
using Rail.Net.Common;
using Rail.Net.Core.Interfaces.Data;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data
{
    public class PriceDomesticRepository : Repository<PriceDomestic>, IPriceDomesticRepository
    {
        #region IPriceDomesticRepository Members

        public IEnumerable<PriceDomestic> GetPriceDomestics(bool isDomesticOnly, int distance)
        {
            return AllDefaultsIncluded().Where(
                p =>
                p.TarifNumber == 1 && p.SubRu == "0" &&
                (p.Class == Constants.FirstClassNumber || p.Class == Constants.SecondClassNumber) &&
                p.TrainType == (isDomesticOnly ? 0 : 1) &&
                p.ZoneFrom <= distance && p.ZoneTo >= distance &&
                p.ValidFrom <= DateTime.Now && p.ValidTo >= DateTime.Now);
        }

        #endregion
    }
}